<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 18.5.16
 * Time: 17:28
 */

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuthController extends Controller
{
    public function getLogin()
    {
        echo "something";
    }

    public function postLogin(Request $request)
    {
        $account = $request->input("account");

        $password = $request->input("password");

        if (Auth::guard("admin")->attempt(["account" => $account, "password" => $password])) {
            // 认证通过
            return $this->successResponse([
                "redirect_url" => "/home"
            ]);
        } else {
            return $this->failResponse("用户名或密码错误");
        }
    }

    protected function guard()
    {
        return auth()->guard('admin');
    }
}